import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/home",
    name: "Home",
    component: Home,
  },
  {
    path: "/",
    redirect: '/home'
  },
  {
    path: "/list",
    name: "List",
    component: () =>
      import("../views/List.vue"),
  },
  {
    path: "/cart",
    name: "Cart",
    component: () =>
      import("../views/Cart.vue"),
  },
  {
    path: "/my",
    name: "My",
    component: () =>
      import("../views/My.vue"),
  },
  {
    path: "/search",
    name: "Search",
    children: [
      {
        path: '/',
        name: 'index',
        component: () =>
        import("../views/search/Search-index.vue")
      },
      {
        path: "list",
        name: "list",
        component: () =>
        import("../views/search/Search-list.vue")
      }
    ],
    component: () =>
      import("../views/Search.vue"),
  },
  {
    path: "/detail",
    name: "Detail",
    meta: {
      keepAlive: true //此组件需要被缓存
    },
    component: () =>
      import("../views/Detail.vue"),
  },
  {
    path: "/Login",
    name: "Login",
    component: () =>
      import("../views/login/Login.vue"),
  },
  {
    path: "/goUserLogin",
    name: "goUserLogin",
    component: () =>
      import("../views/login/goUserLogin.vue"),
  },
  {
    path: "/Register",
    name: "Register",
    component: () =>
      import("../views/login/Register.vue"),
  },
  {
    path: "/Recovery",
    name: "Recovery",
    children: [
      {
        path: '/',
        name: 'RecoveryIndex',
        component: () =>
        import("../views/recovery/RecoveryIndex.vue")
      },
      {
        path: "RecoveryBtn",
        name: "RecoveryBtn",
        component: () =>
        import("../views/recovery/RecoveryBtn.vue")
      }
    ],
    component: () =>
      import("../views/recovery/Recovery.vue"),
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
